Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add robust error dialog for when digest cycle is broken #2977

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

Nateowami
Copy link
Collaborator

@Nateowami Nateowami commented Jan 23, 2025

When there's an error in every single digest cycle, the page is completely broken, and not even the error dialog can display. This change adds an extra robust error dialog that is only shown when the normal error dialog is not capable of opening.

The simplest way to cause this to happen is to add an error to a template that will occur every single time. This can be done by adding this to the template:

{{ throwError() }}

And adding this to the associated component:

  throwError(): never {
    throw new Error('This is a test');
  }

The result is that the page fails to update, and is covered with a dialog backdrop, but no actual error dialog. Depending on where the error occurs, the page may be completely rendered and just not able to update, or barely rendered at all:

This change detects this type of situation by listening for the onInit event of the error dialog, and if it hasn't fired within 100ms, assumes the page is broken, and opens a backup error dialog, which is significantly more limited, but more reliable and not dependent on Angular to work. This detection method can have false positives (e.g. performance issues may cause the error dialog to take more than 100ms to open), so if the onInit event fires after the backup dialog has been opened, it is closed to prevent duplicate dialogs.

To test this change, make the described changes to a component, and observe the behavior on this branch and on master.


This change is Reviewable

@Nateowami
Copy link
Collaborator Author

This isn't the only possible approach. We could just make the entire error dialog not depend on Angular, but that seemed more challenging, and this is an edge case. I actually kind of like the fact that when things go this wrong that nothing on the page is going to work anymore, the error dialog appears significantly different.

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 13.33333% with 26 lines in your changes missing coverage. Please review.

Project coverage is 82.02%. Comparing base (28f53f2) to head (42af48a).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...orge-common/error-dialog/error-dialog.component.ts 13.33% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2977      +/-   ##
==========================================
- Coverage   82.08%   82.02%   -0.07%     
==========================================
  Files         544      544              
  Lines       31644    31673      +29     
  Branches     5125     5149      +24     
==========================================
+ Hits        25976    25979       +3     
- Misses       4913     4927      +14     
- Partials      755      767      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@kylebuss kylebuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested on both branches the mentioned steps. Is there a way to test the dialog closes if the onInit completes after 100ms? Also to prevent fewer false positives, should we make it 500ms?

Reviewable status: 0 of 1 files reviewed, all discussions resolved

@kylebuss kylebuss self-assigned this Jan 24, 2025
@Nateowami
Copy link
Collaborator Author

@kylebuss Yes. Add an artificial delay, or reduce the delay down to 0, so it will always mistakenly open. 100ms is a long time in computer terms. I think the system would have to be briefly frozen, and if it's frozen, 500ms probably isn't going to make the difference.

Copy link
Collaborator

@kylebuss kylebuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point. Approving as is.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Nateowami)

@Nateowami Nateowami merged commit dc78e8a into master Jan 24, 2025
17 checks passed
@Nateowami Nateowami deleted the feature/add-robust-error-dialog branch January 24, 2025 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants